{include(header)}
<style>
#id_sendinfo{position:fixed;width:300px;background:#fff;border:1px #ddd solid;border-top:2px #438eb9 solid}
#id_sendinfo ul{float:left;width:300px;margin:0px;padding:20px 0px}
#id_sendinfo ul li{float:left;width:300px;margin:5px 0px}
#id_sendinfo ul .xbtn{text-align:center}
</style>
<div class="pMenu" id="id_pMenu">
	<li style="font-weight:bold"><input type="hidden" name="url_item_id" value="{$admin_item['id']}" id="id_url_item_id"><span class="more1" onmouseover="kj.windiv({'id':'item_user_windiv','fid':this,'src':'common.php?app=vote&app_act=item'});" id="id_shop_user">活动：{if($admin_item['id']<1)}请选择{else}{$admin_item['name']}{/if}</span></li>
	<li class="sel">管理</li>
	<li onclick="admin.menu_display(0);" class = "x_btn">查找</li>
	<li class="fdpic" onclick="master_open({url:'common.php?app=config&app_module=user&dir={$app_dir}&filename=vote&key=vote.award.lottery',title:'设置字段',w:400});">&nbsp;</li>
</div>
<div class="btnMenuDiv" id="id_btnMenuDiv"{if($arr_list['issearch']==0)} style="display:none"{/if}>
<li>类型：<select name="s_type"><option value="-999">不限</option>{foreach($arr_type as $item=>$key)}<option value="1"{if(fun_get::get("s_type")==$key)} selected{/if}>{$item}</option>{/foreach}</select></li>
<li>中奖时间：<input type="text" id="s_time1" name="s_time1" value="{fun_get::get('s_time1')}" class='pTxtDate' onfocus="new Calendar().show(this);"> 到 <input type="text" name="s_time2" id="s_time2" value="{fun_get::get('s_time2')}" class='pTxtDate' onfocus="new Calendar().show(this);"></li>
<li>状态：<select name="s_state"><option value="-999">不限</option><option value="0"{if(fun_get::get("s_state")=='0')} selected{/if}>未发放</option><option value="1"{if(fun_get::get("s_state")=='1')} selected{/if}>已发放</option></select></li>
<li>关 键 字：<input type="text" id="s_key" name="s_key" value="{fun_get::get('s_key')}" class='pTxt1'>　<input type="button" name="btn_s_ok" value="查找" class="pBtn" onclick="admin.search();"> 　<input type="button" name="btn_s_clear" value="清空" class="pBtn" onclick="admin.clear_search();"></li>
</table>
</div>
<div class="pMain" id="id_main">
<div class="pTableBox" id="id_table_box">
	<div class='pTableTit' id="id_table_title">
		<li><span class="x_tit" style="width:25px">&nbsp;</span></li>
		{foreach($arr_list["tabtit"] as $item)}
			<li><span class="x_tit"{if($item["w"]>0)} style="width:{$item["w"]}px"{/if} onclick="admin.table.list1.sort('{$item['key']}')">{$item["name"]}
			{if(isset($arr_list['sort'][$item['key']]))}<img src="images/sort_{$arr_list['sort'][$item['key']]}.png">{/if}</span><span class="x_split"></span></li>
		{/if}
		<li><span class="x_tit" style="cursor:none;width:150px">操作</span></li>
	</div>
	<div class="pTableList" id="id_table_list">
		<div class='pTable' id="id_table">
			{foreach($arr_list['list'] as $item)}
			<div class='pTabRow'>
				<li><input type='checkbox' name='selid[]' value="{$item['lottery_id']}"></li>
				{foreach($arr_list["tabtd"] as $field)}
					{if($field == 'lottery_title')}
					<li><a href="./index.php?lotteryid={$item['lottery_id']}" target="_blank">{$item[$field]}</a></li>
					{else}
					<li>{if(empty($item[$field]))}&nbsp;{else}{$item[$field]}{/if}</li>
					{/if}
				{/foreach}
					<li>
					{if($item['award_type']==0)}
						{if($this_limit->chk_act("send") && $item['award_type']==0)}
							<input type="button" name="btnedit" value="{if($item['lottery_state']==1)}修改{else}发货{/if}" onclick="thisjs.showsend({$item['lottery_id']});" class="pBtn" id="id_btn_{$item['lottery_id']}">
						{/if}
					{/if}
					</li>
			</div>
			{/foreach}
		</div>
	</div>
</div>
</div>
<div class="pPage" id="id_pPage">
{$arr_list['pagebtns']}
</div>
<div class="pFootAct" id="id_pFootAct">
<li>
<label><input type='checkbox' name='selall' value='1'>全选</label>　
<select name="selact" onchange="thisjs.changeact(this.value)" id="id_selact">
	<option value="">--操作--</option>
		{if($this_limit->chk_act("delete"))}<option value="delete">删除</option>{/if}
	</select>
	&nbsp;<input type="button" name="btnExe" value="执行" onclick="thisjs.selact();" class="pBtn">
</li>
</div>
<div id="id_sendinfo" style="display:none">
	<ul>
		<li>发货单号：<input type="text" name="sendid" value="" id="id_sendid"></li>
		<li>快递公司：<input type="text" name="sendname" value="" id="id_sendname"></li>
		<li class="xbtn"><input type="button" name="btnsend" value="发货" class="pBtn" onclick="thisjs.send();">&nbsp;&nbsp;<input type="button" name="btncancel" value="取消" class="pBtn2" onclick="kj.hide('#id_sendinfo');"></li>
	</ul>
</div>
<script src="admin.table.js"></script>
<script>
//初始化表格控件
kj.onload(function(){
admin.table.list1.init('#id_table_title' , '#id_table');
});
//自动保存
admin.table.list1.save_resize = function() {
	var lng_w = (kj.w(this.field));
	kj.ajax.get("common.php?app=config&app_module=user&dir={$app_dir}&app_act=save_resize&filename=vote&key=vote.award.lottery&index=" + this.fieldsindex + "&w=" + lng_w , function(data){
		//alert(data);
	});
}
admin.table.list1.sort = function(key) {
	kj.ajax.get("common.php?app=config&app_module=user&dir={$app_dir}&app_act=sort&key=vote.award.lottery&filename=vote&sortby=" + key , function(data){
			var obj_data=kj.json(data);
			if(!obj_data.isnull) {
				admin.refresh();
			}
	});
}
//当前页面js对象
var thisjs = new function() {
	this.selact = function(val) {
		var act = kj.obj("#id_selact").value;
		admin.selact();
	}
	this.changeact = function(val) {
	}
	this.showsend = function(id) {
		kj.show("#id_sendinfo");
		var offset = kj.offset("#id_sendinfo");
		var w = kj.w();
		var h = kj.h();
		var left = w/2-offset.width/2;
		var top = h/3;
		kj.set("#id_sendinfo","style.left",left+'px');
		kj.set("#id_sendinfo","style.top",top+'px');
		this.sendid = id;
	}
	this.send = function() {
		var objdata = {};
		objdata.id = this.sendid;
		objdata.sendid = kj.obj("#id_sendid").value;
		if(objdata.sendid == '') {
			alert("请填写发货单号");
			kj.obj("#id_sendid").fouce();
			return;
		}
		objdata.sendname = kj.obj("#id_sendname").value;
		if(objdata.sendname == '') {
			alert("请填写发货快递公司");
			kj.obj("#id_sendname").fouce();
			return;
		}
		kj.ajax.post("{fun_get::url(array('app_act'=>'send'))}",objdata,function(data) {
			var obj = kj.json(data);
			if(obj.isnull) {
				alert("系统繁忙");
				return;
			}
			if(obj.code == '0') {
				kj.alert.show("设置成功",function() {
					location.reload(true);
				});
			} else {
				alert(obj.msg);
			}
		});
	}
}
function vote_item_callback(o) {
	if("id" in o) {
		kj.set("#id_url_item_id" , "value" , o.id);
		admin.refresh();
	}
}
{if($admin_item['id']<1)}
kj.onload(function(){
	var objx = kj.obj("#id_shop_user");
	kj.windiv({'id':'item_user_windiv','fid':objx,'src':'common.php?app=vote&app_act=item'});
	kj.handler("#windivitem_user_windiv_body","mouseout",function() {
		kj.show(this.parentNode);
		return;
	});
});
{/if}


</script>
{include(footer)}